package spring.cloud.gateway;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 基于编码配置路由
 *
 * @author Cruise
 * @version 1.0
 * @since 2021/4/5
 */
@Configuration
public class GatewayRouteConfig {

    @Bean
    public RouteLocator baiduRoute(RouteLocatorBuilder builder) {
        return builder.routes().route("baidu",
                r -> r.path("/guonei").uri("https://news.baidu.com/")).build();
    }

    @Bean
    public RouteLocator sinaRoute(RouteLocatorBuilder builder) {
        return builder.routes().route("baidu",
                r -> r.path("/guoji").uri("https://news.baidu.com/")).build();
    }

}
